package com.xoa.controller.attend;

import com.xoa.model.attend.AttendOut;
import com.xoa.model.attend.AttendOutFlowRunPrcs;
import com.xoa.service.attend.AttendOutService;
import com.xoa.util.ToJson;
import com.xoa.util.common.wrapper.BaseWrapper;
import com.xoa.util.common.wrapper.BaseWrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by gsb on 2017/7/17.
 */
@RestController
@RequestMapping("/attendOut")
public class AttendOutController {
    @Autowired
    private AttendOutService attendOutService;

    /**
     * 创建作者:   牛江丽
     * 创建日期:   2017-7-14 下午14:45:00
     * 方法介绍:   查询外出登记
     */
    @RequestMapping(value = "/queryAllAttendOut", produces = { "application/json;charset=UTF-8" })
    ToJson<AttendOutFlowRunPrcs> queryAllAttendOut(@RequestParam(name = "page", required = false, defaultValue = "1") Integer page,
                                                   @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                                   @RequestParam(name = "useFlag", required = false, defaultValue = "true") Boolean useFlag,
                                                           String allow,    HttpServletRequest request){
        return attendOutService.queryAllAttendOut(page,pageSize,useFlag,request,allow);
    }


    @RequestMapping( value="/addAttendOut")
    BaseWrapper addAttendOut(String createDate, HttpServletRequest request){
        return attendOutService.addAllAttendOut(createDate,request);
    }

    @RequestMapping(value = "/backlogAttendList", produces = { "application/json;charset=UTF-8" })
    public BaseWrappers backlogAttendList(HttpServletRequest request, String num,
                                          @RequestParam(name = "page", required = false, defaultValue = "1") Integer page,
                                          @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                          @RequestParam(name = "useFlag", required = false, defaultValue = "true")  Boolean useFlag){
        return attendOutService.backlogAttendList(request,num,page,pageSize,useFlag);
    }
    /**
     * 创建人：季佳伟
     * 创建时间：2017-11-21  下午5:30:17
     * 方法介绍：查询登录人一段时间内的外出状况
     * 参数说明：
     */
    @RequestMapping(value = "/queryAttendOutByUserId", produces = { "application/json;charset=UTF-8" })
    public ToJson<AttendOut> queryAttendOutByUserId(String beginDate, String endDate,HttpServletRequest req){
        return attendOutService.queryAttendOutByUserId(beginDate,endDate,req);
    }


    }
